<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.w3.org/1999/xhtml">
<head>
    <meta charset="UTF-8">
    <title>更新宿舍区</title>
    <link th:href="@{~/assets/layui/css/layui.css}" rel="stylesheet"/>
</head>
<body style="margin: 10px">
<fieldset class="layui-elem-field">
    <legend>宿舍区</legend>
    <input type="text" name="buildingname" id="buildingname" class="layui-input" placeholder="专业"  th:value="${building.name}">
    <input type="text" name="id" id="id" style="display: none" th:value="${building.id}">
</fieldset>
<hr>
<div class="layui-input-inline">
    <div class="layui-form-item">
        <button type="button" class="layui-btn" id="push">提交</button>
    </div>
</div>
</body>
<script th:src="@{~/assets/layui/layui.js}"></script>
<script th:src="@{~/assets/jquery.min.js}"></script>
<script>
    layui.use(['form', 'layedit', 'laydate'], function () {
        var form = layui.form
            , layer = layui.layer
            , layedit = layui.layedit
            , laydate = layui.laydate;


    });
    $("#push").click(function () {

        var buildingname = $("#buildingname").val()
        var id = $("#id").val()
        $.ajax({
            type: "post",
            contentType: "application/x-www-form-urlencoded",
            url: "/api/v1/building/update",
            data: {
                "id":id,
                "buildingname":buildingname
            },
            dataType: "json",
            success: function (data) {
                if (data.resultTypeEnum == 200) {
                    layer.msg("操作成功", {
                        icon: 1
                    });
                    var index = parent.layer.getFrameIndex(window.name);

                    parent.layui.table.reload('test');
                    //关闭父级页面的表格
                }else {
                    layer.msg(data.message, {
                        icon: 5
                    });
                }
            }
        });
    })
</script>
</html>